package servlet;

import ejb.DbBean;
import ejb.HelloBean;

import javax.ejb.EJB;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: ashishov
 * Date: 3/19/13
 * Time: 7:50 PM
 * To change this template use File | Settings | File Templates.
 */
@WebServlet(urlPatterns = "/db.html")
public class DbServlet extends HttpServlet {

    @EJB
    HelloBean helloBean;

    @EJB
    DbBean dbBean;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");
        response.getWriter().append("<html><body><a href='db.html'>Refresh</a>")
                .append("<br/>HelloBean also said: ")
                .append(helloBean.sayHello())
                .append("</body></html>");

         dbBean.doStuff();

    }
}
